﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aribaccio.Device;

namespace BDPAutodetect.Device
{
    /// <summary>
    /// 设备模组类型数据表
    /// </summary>
    public class DeviceModuleTable
    {
        /// <summary>
        /// 静态变量
        /// </summary>
        public static List<DeviceModuleData> Items { get; private set; }
        /// <summary>
        /// 静态构造函数
        /// </summary>
        static DeviceModuleTable()
        {
            Items = new List<DeviceModuleData>();
            InitCreateList();
        }
        /// <summary>
        /// 静态构造函数
        /// </summary>
        public static void InitCreateList()
        {
            if (Items == null) { Items = new List<DeviceModuleData>(); }
            if (Items.Count > 0) Items.Clear();

            Items.Add(new DeviceModuleData(DeviceModule.None, "设备模组0"));
            Items.Add(new DeviceModuleData(DeviceModule.One, "设备模组1"));
            Items.Add(new DeviceModuleData(DeviceModule.Two, "设备模组2"));
            Items.Add(new DeviceModuleData(DeviceModule.Three, "设备模组3"));
            Items.Add(new DeviceModuleData(DeviceModule.Four, "设备模组4"));
            Items.Add(new DeviceModuleData(DeviceModule.Five, "设备模组5"));
            Items.Add(new DeviceModuleData(DeviceModule.Six, "设备模组6"));
            Items.Add(new DeviceModuleData(DeviceModule.Seven, "设备模组7"));
            Items.Add(new DeviceModuleData(DeviceModule.Eight, "设备模组8"));
            Items.Add(new DeviceModuleData(DeviceModule.Nine, "设备模组9"));
            Items.Add(new DeviceModuleData(DeviceModule.Ten, "设备模组10"));
        }
        /// <summary>
        /// [获取设备检测类型列表集合]
        /// [根据设备类型枚举]
        /// </summary>
        /// <param name="argModuleType">设备模组类型</param>
        /// <returns></returns>
        public static DeviceModuleData? GetDeviceMeasureType(DeviceModule argModuleType)
        {
            try
            {
                if (Items == null || Items.Count <= 0) { InitCreateList(); }
                return Items?.Where(v => v.ModuleType == argModuleType).FirstOrDefault();
            }
            catch (Exception)
            {
                return default;
            }
        }
    }
}
